package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface UserMapper {

    @Select("select * from user where openid = #{openid}")
    User getByOpenId(String openid);

    /*
    *
    * 插入新用户的基础信息
    *
    * */
    void insert(User user);

    @Select("select * from user where id = #{userId}")
    User getById(Long userId);

    /**
     * 获取当天的用户总量
     * @param map
     * @return
     */
    @Select("select count(id) from user where create_time < #{end}")
    Integer getTotalUserStatistics(Map map);

    /**
     * 获取当天的新增用户总量
     * @param map
     * @return
     */
    @Select("select count(id) from user where create_time between #{begin} and #{end}")
    Integer getNewUserStatistics(Map map);
}
